//
//  MainViewController.swift
//  SinaWeibo
//
//  Created by eport_user1 on 2017/10/12.
//  Copyright © 2017年 eport_user1. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.addChildControllers()
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    func addChildControllers() -> Void {
        
        addAChild(child: HomeViewController(), title: "首页", imageName:"home")
        addAChild(child: XGViewController(), title: "西瓜视频", imageName: "video")
        addAChild(child:LittleViewController(), title: "微消息", imageName: "weitoutiao")
        addAChild(child:HSViewController(), title: "火山小视频", imageName: "huoshan")
        
    }
   
    func addAChild(child:UIViewController,title:String,imageName:String) -> Void {
        
        
        child.title = title
        child.tabBarItem.image = UIImage(named:imageName + "_tabbar_32x32_")
        child.tabBarItem.selectedImage = UIImage(named:imageName + "_tabbar_press_32x32_")
        
        let nav = UINavigationController()
        nav.addChildViewController(child);
    
        tabBar.tintColor = UIColor.red;
        addChildViewController(nav);
    }
    

}
